import 'package:base_flutter/base_flutter.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:ls_work/ui/meter_reading/meter_reading_room_page.dart';

class MeterReadingHomePage extends StatefulWidget {
  final String? buildingName;
  final String? floorName;
  final String? buildingId;
  final String? floorId;

  MeterReadingHomePage(
      {this.buildingName, this.floorName, this.buildingId, this.floorId});

  @override
  State<StatefulWidget> createState() => _MeterReadingHomeState();
}

class _MeterReadingHomeState extends State<MeterReadingHomePage> {
  var items = [
    {"name": "电表", "type": 10},
    {"name": "水表", "type": 9},
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("能耗抄表"),
        ),
        body: DefaultTabController(
          length: items.length,
          child: Column(
            children: [
              TabBar(
                tabs: items
                    .map((e) => Tab(
                          text: e['name'] as String,
                        ))
                    .toList(),
                labelColor: Colors.blue,
                labelStyle: TextStyle(fontSize: 16),
                indicatorSize: TabBarIndicatorSize.label,
                unselectedLabelColor: Colors.grey[700],
              ),
              TabBarView(
                      children: items
                          .map((e) => MeterReadingRoomPage(
                                buildingId: widget.buildingId,
                                buildingName: widget.buildingName,
                                floorId: widget.floorId,
                                floorName: widget.floorName,
                                type: e['type'],
                              ))
                          .toList())
                  .setWeight(1)
            ],
          ),
        ));
  }
}
